<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
include ("../../include/dbFunctions.php");
include ("../../include/image_slider.php");
include ("../../include/function.php");

if (isset($_SESSION['school_id'])) {
    $rep_id = $_SESSION['school_id'];
  
    //Select school id
    $school_id = "SELECT * FROM contact_school WHERE contact_school_id = $rep_id";
    $school_id = executeSelectQuery($school_id);
    $school_id = $school_id[0]['school_id'];
// Select school information
    $school = "SELECT * FROM school s, education e WHERE s.education_id = e.education_id AND s.school_id = $school_id";
    $school = executeSelectQuery($school);

/* Select school contact
    $contactResult = "SELECT * FROM contact_school WHERE school_id = $school_id";
    $contactResult = executeSelectQuery($contactResult);
*/
 //select school education level
    $education = "SELECT s.education_id, e.education_name FROM school s, education e  WHERE s.education_id = e.education_id AND s.school_id = $school_id ";
    $education = executeSelectQuery($education);
//select school location
    $location = "SELECT s.location_id, l.location_name FROM school s, location l  WHERE s.location_id = l.location_id AND s.school_id = $school_id";
    $location = executeSelectQuery($location);
}
?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->

<html>
    <head>
        <title></title>
        <title>Junior Achievement Singapore</title>
        <link href="../../media/css/styles.css" rel="stylesheet" type="text/css" />

        <script type="text/javascript" language="javascript" src="../../media/js/jquery/jquery-1.6.1.min.js"></script>

        <script type="text/javascript" src="../../media/js/jqueryUI/jquery-ui-1.8.13.custom.js"></script>
        <script type="text/javascript" src="../../media/js/jquery/jqdialog.min.js"></script>
        <script type="text/javascript" src="../../media/js/jqueryUI/jquery.ui.dialog.js"></script>
        <script type="text/javascript" src="../../media/js/jquery/image_slider.js"></script>
        <!-- Custom jquery scripts -->
        <script src="../../media/js/jquery/custom_jquery.js" type="text/javascript"></script>

        <style type="text/css" title="currentStyle">

            @import "../../media/css/jquery-ui-1.8.13.custom.css";
        </style>
        <link type="text/css" href="../../media/css/dataTable.css" rel="stylesheet" />
        <script type="text/javascript" language="javascript" src="../../media/js/jquery/dataTable.js"></script>
        <script type="text/javascript" language="javascript" src="../../media/js/jquery/jquery.dataTables.editable.js"></script>
        <script type="text/javascript" language="javascript" src="../../media/js/jquery/jquery.jeditable.js"></script>
        <script type="text/javascript" language="javascript" src="../../media/js/jquery/jquery.validate.js"></script>

        <script type="text/javascript" language="javascript" charset="utf-8">
            // active & inactive account

            $(document) .ready(function(){

                $('#contact_details').dataTable( {
                     "sPaginationType": "full_numbers"
                } );


            });
        </script>

    </head>
    <body>
        <script>
            var timeout    = 500;
            var closetimer = 0;
            var ddmenuitem = 0;

            function jsddm_open()
            {  jsddm_canceltimer();
                jsddm_close();
                ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

            function jsddm_close()
            {  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

            function jsddm_timer()
            {  closetimer = window.setTimeout(jsddm_close, timeout);}

            function jsddm_canceltimer()
            {  if(closetimer)
                {  window.clearTimeout(closetimer);
                    closetimer = null;}}

            $(document).ready(function()
            {  $('#navigation > li').bind('mouseover', jsddm_open)
                $('#navigation > li').bind('mouseout',  jsddm_timer)});

            document.onclick = jsddm_close;

        </script>
        <div id="container"><!--CONTAINER STARTS-->
            <div id="navigation">
                <li><a href="../../include/home/homepage.php">HOME</a></li>
                <li><a href="../../include/home/contact.php">CONTACT</a></li>
                <li><a href="http://ja.org.sg/">ABOUT JA SINGAPORE</a></li>
                <li><a href="http://jascheduling.lefora.com/">FEEDBACK</a></li>
                <li><a href="../../guide/guide_menu.php">HELP</a></li>

            </div>
            <div id="title"><!--TITLE STARTS-->
            </div><!--TITLE ENDS-->
            <div id="featured"><!--FEATURED AREA STARTS-->
                <div class="featured-image"><!--FEATURED IMAGE STARTS-->
                    <img alt="Featured Image" src="../../media/images/featured_image.png">
                </div><!--FEATURED IMAGE ENDS-->
                <div class="featured-text"><!--FEATURED TEXT STARTS-->
                    <h2>Welcome to JA Singapore</h2>
                    <p>Junior Achievement programs help prepare young people for the real world by showing them how to generate wealth and effectively manage it, how to create jobs which make their communities more robust, and how to apply entrepreneurial thinking to the workplace. <a href="http://www.jaworldwide.org/">Read More... </a></p>
                </div><!--FEATURED TEXT ENDS-->
            </div><!--FEATURED AREA ENDS-->
            <?php
                    custom_login();
            ?>
                    <div id="left-content"><!--RIGHT CONTENT STARTS-->

                        <div class="left-top"><!--RIGHT CONTENT BOX TOP-->
                        </div><!--RIGHT CONTENT BOX TOP ENDS-->
                        <div class="left-middle"><!--RIGHT CONTENT BOX MIDDLE-->
                    <?php
                   
                      if (!isset($_SESSION['school_id'])) {
                      echo "<br/><br/><br/><br/><br/><center><h3>You don't have permission to view this page<h3><br/>
                      Please login to access the page.</center><br/><br/><br/><br/><br/><br/><br/><br/>";
                      } else {
                   
                    ?>  <h3>School Details</h3>

                    <table id="details" class="tabledetail">
                        <!-- Print out school details-->
                        <tr>
                            <th class="tabledetailth">School Name: </th>
                            <td><?php echo $school[0]['school_name'] ?></td>
                        </tr>
                        <tr>
                            <th class="tabledetailth">School Description: </th>
                            <td><?php echo $school[0]['school_description'] ?></td>
                        </tr>
                        <tr>
                            <th class="tabledetailth">School Status: </th>
                            <td><?php echo $school[0]['school_status'] ?></td>
                        </tr>
                        <tr>
                            <th class="tabledetailth">School Address: </th>
                            <td><?php echo $school[0]['school_address'] ?></td>
                        </tr>
                        <tr>
                            <th class="tabledetailth">School Postal: </th>
                           <td><?php echo $school[0]['school_postal'] ?></td>
                        </tr>
                          <tr>
                            <th class="tabledetailth">Education level: </th>
                            <td>
                                <?php echo $education[0]['education_name'] ?>
                            </td>
                        </tr>
                        <tr>
                            <th class="tabledetailth">Location: </th>
                            <td>
                                <?php echo $location[0]['location_name'] ?>
                            </td>
                        </tr>
                         <tr>
                            <th class="tabledetailth">Created Date: </th>
                            <td><?php echo $school[0]['created_date'] ?></td>
                        </tr>
                         <tr>
                            <th class="tabledetailth">Modified date: </th>
                            <td><?php echo $school[0]['last_modified'] ?></td>
                        </tr>
                    </table>
                    <br>
                    <table  cellpadding="0" cellspacing="0" border="0" class="display" id ="contact_details">
                        <thead>
                        <tr>
                            <th>Representative</th>
                            <th> Email</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        $contact = "SELECT * FROM contact_school WHERE school_id = $school_id";
                        $contact = executeSelectQuery($contact);

                        for ($i = 0; $i <count($contact); $i++){
                        ?>
                        <tr>
                        <td> <?php echo $contact[$i]['contact_name']; ?></td>
                        <td> <?php echo $contact[$i]['contact_email']; ?></td>
                        </tr>
                        <?php
                        }
                        ?>
                        </tbody>
                    </table>
                    <br/>


                    <input type="button" value="&nbsp" onclick='history.go(-1)' class="form-back"/>



                    <?php
                                }
                    ?>
                </div><!--RIGHT CONTENT BOX MIDDLE ENDS-->
                <div class="left-bottom"><!--RIGHT CONTENT BOX BOTTOM-->
                </div><!--RIGHT CONTENT BOX BOTTOM ENDS-->
            </div><!--RIGHT CONTENT ENDS-->
        </div><!--CONTAINER ENDS-->
        <div id="footer"><!--FOOTER STARTS-->
            <p>Copyright &copy; Junior Achievement Singapore | All Rights Reserved</p>
        </div><!--FOOTER ENDS-->
    </body>
</html>
